package com.example.happiness.mapper;

import com.example.happiness.pojo.Chat;
import com.example.happiness.pojo.adminvo.AdminChatVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ChatMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(Chat record);

    int insertSelective(Chat record);

    Chat selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Chat record);

    int updateByPrimaryKey(Chat record);

    @Select("select usertype,content,time from chat where userid=#{userid} ORDER BY time")
    List<Chat> getChats(String userid);

    @Select("SELECT DISTINCT userid\n" +
            "FROM chat")
    List<String> getUserList();

    @Select("select admintype,content,time from chat where userid=#{userid} ORDER BY time")
    List<Chat> getChatList(String userid);

    @Select("select id, usertype, admintype, content, time, userid from chat")
    List<Chat> selectChatList();
}